<?php

use yii\helpers\Url;
use yii\helpers\Html;  

$this->title = '昊祥科技-会员中心';
$signPackage = \app\components\Jssdk::getSignPackage();
?>
<?=Html::jsFile('https://res.wx.qq.com/open/js/jweixin-1.2.0.js')?>  
<iframe id='userMsg' name='userMsg' src="https://webform.xgate.com/app/index.php/webforms/form/form?encid=b004a460-3ad7-75f1-7bd2-1fbadbb9cac6&tracker=350e92b9-5986-4f05-f72c-77289fac5343" frameborder="0" width=0 height=0></iframe>
<style>
	.test{
	    text-align: center; /*让div内部文字居中*/
	    background-color: #fff;
	    border-radius: 20px;
	    width: 300px;
	    height: 350px;
	    margin: auto;
	    position: absolute;
	    top: 0;
	    left: 0;
	    right: 0;
	    bottom: 0;
	}
</style>
<div class="test">
 恭喜你激活成功页面6秒后自动关闭.
</div>
<script>
var data = {
		last_name: "<?= $data['last_name']?>",
		mobile: "<?= $data['mobile']?>",
		gender: "<?= $data['gender']?>",
		email: "<?= isset($data['email'])?$data['email']:""?>",
		openid: "<?= $data['wechat_openid']?>",
		birth_yyyy:"<?= isset($data['birth_yyyy'])?$data['birth_yyyy']:""?>",
		birth_mm:"<?= isset($data['birth_mm'])?$data['birth_mm']:""?>",
		birth_dd:"<?= isset($data['birth_dd'])?$data['birth_dd']:""?>",
}


var signPackage = <?= json_encode($signPackage) ?>;
    console.log(signPackage);
    wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: signPackage.appId, // 必填，公众号的唯一标识
    timestamp: signPackage.timestamp, // 必填，生成签名的时间戳
    nonceStr: signPackage.nonceStr, // 必填，生成签名的随机串
    signature: signPackage.signature,// 必填，签名，见附录1
    jsApiList: [
                'onMenuShareTimeline',
                'onMenuShareAppMessage',
                'onMenuShareQQ',
                'onMenuShareWeibo',
                'onMenuShareQZone',
                'startRecord',
                'stopRecord',
                'onVoiceRecordEnd',
                'playVoice',
                'pauseVoice',
                'stopVoice',
                'onVoicePlayEnd',
                'uploadVoice',
                'downloadVoice',
                'chooseImage',
                'previewImage',
                'uploadImage',
                'downloadImage',
                'translateVoice',
                'getNetworkType',
                'openLocation',
                'getLocation',
                'hideOptionMenu',
                'showOptionMenu',
                'hideMenuItems',
                'showMenuItems',
                'hideAllNonBaseMenuItem',
                'showAllNonBaseMenuItem',
                'closeWindow',
                'scanQRCode',
                'chooseWXPay',
                'openProductSpecificView',
                'addCard',
                'chooseCard',
                'openCard',
                ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });

    wx.ready(function(){  
    	window.frames.userMsg.postMessage(data, "*");

    	window.addEventListener("message", function (e) {
    		alert(1)
    		if (e.data == "isAppointmentSuccess") {
    			setTimeout(function(){
    				//$(".lds-modal").css("display", "none");
    				// window.location.reload();
    				//window.location.href = memberIndexUrl
    				wx.closeWindow();
    			}, 6400);
    		}
    	})
       //wx.closeWindow();
        // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
    });
    
    wx.error(function(res){
        console.log(res);
        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
    });
    
</script>